home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************
- ;
- ; intmult.asm
- ;
- ; staff
- ;
- ; 05-02-91
- ;
- ; (C) Texas Instruments Inc., 1992
- ;
- ; Refer to the file 'license.txt' included with this
- ; this package for usage and license information.
- ;
- ;**************************************************************
- Example 7-xx. 32-bit Integer Multiplication
-
-
-
- .title "32-bit Optimized Integer Multiplication"
- .def MPY32
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; This routine multiplies two 32-bit signed integers resulting
- ; in a 64-bit product. The operands are fetched from data
- ; memory and the result is written back to data memory.
- ; Data Storage:
- ; X1,X0 32-bit operand
- ; Y1,Y0 32-bit operand
- ; W3,W2,W1,W0 64-bit product
- ; Entry Conditions:
- ; DP = 6, SXM = 1
- ; OVM = 0
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- X1 .set 300h ;DP=6
- X0 .set 301h ;DP=6
- Y1 .set 302h ;DP=6
- Y0 .set 303h ;DP=6
- W3 .set 304h ;DP=6
- W2 .set 305h ;DP=6
- W1 .set 306h ;DP=6
- W0 .set 307h ;DP=6
-
-
- .text
-
-
- MPY32: BIT X0,0 ;TC = X0 bit#15
- LT X0 ;T = X0
- MPYU Y0 ;P = X0Y0
- SPL W0 ;Save W0
- SPH W1 ;Save partial W1
- MPY Y1 ;P = X0Y1
- LTP X1 ;Acc = X0Y1, T = X1
- MPY Y0 ;P = X1Y0
- MPYA Y1 ;Acc = X0Y1+X1Y0, P=X1Y1
- ADDS W1 ;Acc = X0Y1+X1Y0+X0Y02^-16
- SACL W1 ;Save final W1
- BSAR 16 ;Shift Acc right by 16
- XC 1,TC ;If MSB of X0 is 1
- ADD Y1 ;Add Y1
- BIT Y0,0 ;TC = Y0 bit#15
- APAC ;ACC = X1Y1 + (X0Y1+X1Y0)2^-16
- XC 1,TC ;IF MSB of Y0 is 1
- ADD X1 ;Add X1
- SACL W2 ;Save W2
- SACH W3 ;Save W3